Importing the required modules¶

In [1]:
import numpy as np
import pandas as pd
import librosa 
import IPython.display as ipd
import speech_recognition as sr
import os
from IPython.display import Audio
from IPython.utils import io
from pathlib import Path
import pyttsx3

Finding the audio files from local storage¶

In [2]:
for file in os.listdir('Audios'):
    print(file)
Athlete-Hima-Das.wav
DR APJ ABDUL_KALAM English_Speech.wav
MP3 format
SP-Balasubramaniam Speech.wav
The Super Mario Effect Tricking Your Brain 1.wav
The Super Mario Effect Tricking Your Brain 2.wav
The Super Mario Effect Tricking Your Brain 3.wav
The Super Mario Effect Tricking Your Brain.wav

Attempt to play the 1 minute full audio¶

In [3]:
a = ipd.Audio('Audios\The Super Mario Effect Tricking Your Brain.wav')
a
Out[3]:
Your browser does not support the audio element.

Extracting the Text from the Audio clip1¶

In [4]:
file_path1 = 'Audios\The Super Mario Effect Tricking Your Brain 1.wav'
r = sr.Recognizer()  # Initialize the Recognizer

with sr.AudioFile(file_path1) as source:  # Recognize the speech from the audio file1
    audio_data = r.record(source)
    text_audio_1 = r.recognize_google(audio_data)    # Storing into a variable

Extracting the Text from the Audio clip2¶

In [5]:
file_path2 = 'Audios\The Super Mario Effect Tricking Your Brain 2.wav'

with sr.AudioFile(file_path2) as source:  # Recognize the speech from the audio file2
    audio_data = r.record(source)
    text_audio_2 = r.recognize_google(audio_data)    # Storing into a variable

Extracting the Text from the Audio clip3¶

In [6]:
file_path3 = 'Audios\The Super Mario Effect Tricking Your Brain 3.wav'

with sr.AudioFile(file_path3) as source:  # Recognize the speech from the audio file3
    audio_data = r.record(source)
    text_audio_3 = r.recognize_google(audio_data)    # Storing into a variable

Merging the Audio clips¶

In [7]:
final_text = text_audio_1 + " " + text_audio_2 + " " + text_audio_3

Printing the final text output:¶

In [8]:
print(final_text)
we show the slightly different message stating that you lost 5 points from your starting 200 points how is the only difference in one version if you fail recently took away 5 no value in the rural no one will ever series completely meaning with fake internet point is crucial the keep in mind for the results are about to show you from the 50000 8000 52% brothers who are not penalize there was 68% that's to significant 60% was really surprising and almost believe and two elect another piece of data solve before finding success it's shown in Android here so those who didn't see feeling in negative life newly had to the half times more times to solve the puzzle as a result

Generating speech to a specific person from the target speaker's natural voice.¶

In [9]:
final_txt = Path("Audios\SP-Balasubramaniam Speech.wav")
audio = pyttsx3.init()
audio.setProperty('rate', 120)
audio.setProperty('volume', 0.2)


audio.say(final_text)

audio.runAndWait()
In [ ]:
 
In [ ]: